package com.dao;

import com.model.MyClass;
import utils.DBUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class MyClassDao {
    public int insert(MyClass record) {
        Connection connection = null;
        PreparedStatement statement = null;

        try {
            connection = DBUtil.getConnection();
            String sql = "insert into class (name) values (?)";
            statement = connection.prepareStatement(sql);
            statement.setString(1, record.getName());
            int row = statement.executeUpdate();
            return row;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            DBUtil.closeConnection(null, statement, connection);
        }
    }
}
